@use './variables.scss' as *;

// 弹性布局混合
@mixin flex-center {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
}

@mixin flex-between {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

@mixin flex-column {
  display: flex;
  flex-direction: column;
}

@mixin flex-column-center {
  @include flex-column;
  justify-content: center;
  align-items: center;
}

// 按钮样式混合
@mixin button-base {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: $spacing-sm $spacing-md;
  border: none;
  border-radius: $border-radius-md;
  font-size: $font-size-md;
  font-weight: $font-weight-medium;
  cursor: pointer;
  transition: all $transition-normal;
  text-decoration: none;
  outline: none;
  
  &:hover {
    opacity: $btn-hover-opacity;
  }
  
  &:active {
    opacity: $btn-active-opacity;
  }
  
  &:disabled {
    opacity: $btn-disabled-opacity;
    cursor: not-allowed;
  }
}

@mixin button-primary {
  @include button-base;
  background-color: $primary-color;
  color: $text-light;
}

@mixin button-secondary {
  @include button-base;
  background-color: $secondary-color;
  color: $text-light;
}

@mixin button-accent {
  @include button-base;
  background-color: $accent-color;
  color: $text-light;
}

@mixin button-outline {
  @include button-base;
  background-color: transparent;
  border: 2px solid $primary-color;
  color: $primary-color;
}

// 卡片样式混合
@mixin card {
  background-color: $bg-card;
  border-radius: $border-radius-lg;
  box-shadow: $shadow-medium;
  padding: $spacing-lg;
}

@mixin card-hover {
  @include card;
  transition: all $transition-normal;
  
  &:hover {
    box-shadow: $shadow-heavy;
    transform: translateY(-2px);
  }
}

// 文本样式混合
@mixin text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@mixin text-clamp($lines: 2) {
  display: -webkit-box;
  -webkit-line-clamp: $lines;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

// 响应式混合
@mixin mobile {
  @media (max-width: 768px) {
    @content;
  }
}

@mixin tablet {
  @media (min-width: 769px) and (max-width: 1024px) {
    @content;
  }
}

@mixin desktop {
  @media (min-width: 1025px) {
    @content;
  }
}

// 位置混合
@mixin absolute-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@mixin absolute-full {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

// 动画混合
@mixin fade-in($duration: $transition-normal) {
  animation: fadeIn $duration ease-in-out;
}

@mixin slide-up($duration: $transition-normal) {
  animation: slideUp $duration ease-out;
}

@mixin bounce-in($duration: $transition-slow) {
  animation: bounceIn $duration ease-out;
}

// 游戏特定混合
@mixin game-button {
  @include button-base;
  background: linear-gradient(135deg, $primary-color, darken($primary-color, 10%));
  color: $text-light;
  font-size: $font-size-lg;
  padding: $spacing-md $spacing-xl;
  border-radius: $border-radius-xl;
  box-shadow: $shadow-medium;
  
  &:hover {
    transform: translateY(-2px);
    box-shadow: $shadow-heavy;
  }
}

@mixin level-badge($color) {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  background-color: $color;
  color: $text-light;
  border-radius: $border-radius-round;
  font-size: $font-size-sm;
  font-weight: $font-weight-bold;
  padding: $spacing-xs $spacing-sm;
  min-width: 24px;
  height: 24px;
}

@mixin star-rating {
  display: flex;
  flex-direction: row;
  gap: $spacing-xs;
  
  .star {
    width: 20px;
    height: 20px;
    color: $star-empty;
    transition: color $transition-fast;
    
    &.filled {
      color: $star-filled;
    }
  }
}

// 模态框混合
@mixin modal-overlay {
  @include absolute-full;
  background-color: $bg-overlay;
  @include flex-center;
  z-index: $z-index-modal;
}

@mixin modal-content {
  @include card;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn $transition-normal ease-out;
}

// 加载动画混合
@mixin loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid $border-light;
  border-top: 4px solid $primary-color;
  border-radius: $border-radius-round;
  animation: spin 1s linear infinite;
}

// 关键帧动画
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}